module Singly
  class Services
    module Service

      def self.included(base)
        base.class_eval do
          include Singly::Endpoint
          endpoint :get, "/services/:service", required: [:access_token]
        end
      end

      def service_endpoint(endpoint_name, params)
        params ||= {}
        endpoint_type = params.has_key?(:id) ? Singly::Services::IdEndpoint : Singly::Services::Endpoint
        endpoint_type.new(creds.merge(params.merge({
          service: @service,
          endpoint: endpoint_name.to_s
        })))
      end

      def service=(service)
        @service = service
      end
    end
  end
end